#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<limits.h>

const int MOD_VAL = INT_MAX;

int main(int argc, char *argv[])
{
	int j, i;
	int N;
	int d; 
	char c[200];
	int fd;
	int rand_num;

	if(argc < 2)
	{
		printf("enter 1 args:\n./randomN <N>\n");
		return 0;
	}

	N = atoi(argv[1]);
	
	srand( time(NULL) );

	sprintf(c, "data/%d-file", N);
	fd = open(c, O_CREAT | O_RDWR, 0777);


	for(j = 0; j < N; j++)
	{
		rand_num = rand() % MOD_VAL;	
		if(write(fd, &rand_num, sizeof(int)) == -1)
		{
			perror("write failed\n");
		}
	}

	close(fd);

	return 0;
}
